home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videoedt / vddtprvw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  7.6 KB  |  293 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoEdit/RCS/VideoEditPreview.c,v 0.19 92/01/03 15:49:43 drapeau Exp Locker: drapeau $ */
  25. /* $Log:    VideoEditPreview.c,v $
  26.  * Revision 0.19  92/01/03  15:49:43  drapeau
  27.  * Changed occurrances of "NULL" in calls to Browse() to use "0" instead.
  28.  * This is due to the ANSI definition of NULL as "(void*)0".
  29.  * Also, modified function PlayMode() to more clearly show the logic
  30.  * of the function, using defined constants from VideoObject library
  31.  * to set current audio setting.
  32.  * 
  33.  * Revision 0.18  91/09/24  21:36:53  lim
  34.  * Changed 'vEdit' to 'VideoEdit' everywhere.
  35.  * 
  36.  * Revision 0.17  91/08/16  13:12:08  lim
  37.  * xsaber-ed the code.
  38.  * 
  39.  * Revision 0.16  91/08/07  13:29:04  lim
  40.  * 1.Added instance pointer, "theObject" to all public function calls.
  41.  * 2. Duration for PreviewStart and PreviewEnd corrected.
  42.  * 
  43.  * Revision 0.15  91/08/02  13:02:15  lim
  44.  * 'currentAudio' is used in preview rather than audioStg[editnum]
  45.  * 
  46.  * Revision 0.14  91/07/29  22:30:09  lim
  47.  * Updated status codes to conform with specs.
  48.  * Duration in previewing start/end n seconds of
  49.  * edit corrected to take into account speed of edit.
  50.  * 
  51.  * Revision 0.13  91/07/27  22:29:34  lim
  52.  * Changed speed from double to int.
  53.  * 
  54.  * Revision 0.12  91/07/24  11:03:19  lim
  55.  * Ran through xsaber - fixed warnings.
  56.  * 
  57.  * Revision 0.11  91/07/19  14:14:08  lim
  58.  * Added PlayMode.
  59.  * 
  60.  * Revision 0.10  91/07/12  16:21:08  lim
  61.  * Initial revision implementing VideoObject.
  62.  *  */
  63.  
  64. #include "VideoEdit.h"
  65.  
  66. static char prevrcs[] = "$Header: /Source/Media/collab/VideoEdit/RCS/VideoEditPreview.c,v 0.19 92/01/03 15:49:43 drapeau Exp Locker: drapeau $";
  67.  
  68.  
  69. /*     EDIT PREVIEW FUNCTIONS (POPUP WINDOW 3)    */
  70.  
  71.  
  72. /* Does the standard checks for playing from `start' to `end' in `mode' */
  73. void
  74. PlayMode(mode, start, end)
  75.      int mode;
  76.      int start;
  77.      int end;
  78. {
  79.   int err;
  80.   int speed;
  81.   
  82.   err = DevSetAddMode(myVideo, mode);                    /* set addressing mode */
  83.   if (err == -1)
  84.     return;
  85.   
  86.   if (currentAudio == Mute)
  87.     DevSetAudio(myVideo, PlayerAudioMute);                /* Set audio */
  88.   else
  89.     if (currentAudio == Right)
  90.       DevSetAudio(myVideo, PlayerAudioRight);
  91.     else
  92.       if (currentAudio == Left)
  93.     DevSetAudio(myVideo, PlayerAudioLeft);
  94.       else
  95.     if (currentAudio == Stereo)
  96.       DevSetAudio(myVideo, PlayerAudioStereo);
  97.   speed =  (int) xv_get(VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  98.   DevPlayFromTo(myVideo, start, end, speed);                /* Play segment at set speed */
  99. }
  100.  
  101.  
  102. /*
  103.  * Menu handler for `previewMenu (Play entire edit)'.
  104.  * Default : Play the current selection from start to end.
  105.  */
  106. Menu_item
  107. PreviewStartEnd(item, op)
  108.      Menu_item    item;
  109.      Menu_generate    op;
  110. {
  111.   int start;
  112.   int end;
  113.   int value;
  114.   int result;
  115.   
  116.   switch (op) 
  117.   {
  118.    case MENU_DISPLAY:
  119.     break;
  120.     
  121.    case MENU_DISPLAY_DONE:
  122.     break;
  123.     
  124.    case MENU_NOTIFY:
  125.     
  126.     /* get start and end frames */
  127.  
  128.     start = xv_get (VideoEdit_editPopup->editStartTxt, PANEL_VALUE);
  129.     end = xv_get (VideoEdit_editPopup->editEndTxt, PANEL_VALUE);
  130.  
  131.     (void) SetDuration();
  132.     
  133.     result = CheckSelection(start, end);                /* check if selection is valid */
  134.     if (result == -1) return item;  
  135.     
  136.     PlayMode(PlayerFrameMode, start, end);
  137.     
  138.     /* check if search status is frame or chapter */
  139.     value = xv_get(VideoEdit_optionsPopup->optionsSearchStg, 
  140.            PANEL_VALUE);
  141.     if (value == 1) 
  142.       DevSetAddMode(myVideo, PlayerChapterMode);
  143.  
  144.     break;
  145.     
  146.    case MENU_NOTIFY_DONE:
  147.     break;
  148.   }
  149.   return item;
  150.    
  151. }
  152.  
  153.  
  154. /*
  155.  * Notify callback function for `previewPlayFirstButton'.
  156.  * Play the first x seconds of the current selection.
  157.  */
  158. void
  159. PreviewStart(item, event)
  160.      Panel_item      item;
  161.      Event           *event;
  162. {
  163.   
  164.   int start;
  165.   int end;
  166.   int speed;
  167.   int duration;
  168.   int value;
  169.   int result;
  170.   
  171.   /* get start and end frames */
  172.  
  173.   start = xv_get (VideoEdit_editPopup->editStartTxt, PANEL_VALUE);
  174.   end = xv_get (VideoEdit_editPopup->editEndTxt, PANEL_VALUE);
  175.   speed = xv_get (VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  176.  
  177.   result = CheckSelection(start, end);                    /* check if selection is valid */
  178.   if (result == -1) return; 
  179.   
  180.   /* get the duration to be played */
  181.  
  182.   duration = xv_get (VideoEdit_previewPopup->previewPlayFirstTxt, 
  183.              PANEL_VALUE);
  184.   if (end > (start + duration*speed))
  185.     end = start + duration*speed;                    /* convert into frame numbers */
  186.   
  187.   PlayMode(PlayerFrameMode, start, end);
  188.   
  189.   /* check if search status is frame or chapter */
  190.   value = xv_get(VideoEdit_optionsPopup->optionsSearchStg, 
  191.          PANEL_VALUE);
  192.   if (value == 1) 
  193.     DevSetAddMode(myVideo, PlayerChapterMode);
  194.   
  195. }
  196.  
  197. /*
  198.  * Notify callback function for `previewPlayFirstTxt'.
  199.  */
  200. Panel_setting
  201. PreviewStartTxt(item, event)
  202.      Panel_item    item;
  203.      Event        *event;
  204. {
  205.   
  206.   if (event_action(event) != '\r')
  207.     return (0);
  208.   if (search == 1)
  209.     search = 0;
  210.   else 
  211.   {
  212.     PreviewStart(item, event);
  213.     search = 1;
  214.   }
  215.   
  216. }
  217.  
  218.  
  219.  
  220. /* Notify callback function for `previewPlayLastButton'.
  221.  * Play the last x seconds of the current selection.
  222.  */
  223. void
  224. PreviewEnd(item, event)
  225.      Panel_item      item;
  226.      Event           *event;
  227. {
  228.   int start;
  229.   int end;
  230.   int speed;
  231.   int duration;
  232.   int value;
  233.   int result;
  234.   
  235.   
  236.   /* get start and end frame numbers */
  237.   start = xv_get (VideoEdit_editPopup->editStartTxt, PANEL_VALUE);
  238.   end = xv_get (VideoEdit_editPopup->editEndTxt, PANEL_VALUE);
  239.   speed = xv_get (VideoEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  240.                                     
  241.   result = CheckSelection(start, end);                    /* check if selection is valid */
  242.   if (result == -1) return;                        
  243.   
  244.   /* get the duration to be played */
  245.   duration = xv_get (VideoEdit_previewPopup->previewPlayLastTxt, 
  246.              PANEL_VALUE);
  247.   if (start < (end - duration*speed))
  248.     start = end - duration*speed;                    /* convert into frame numbers */
  249.   
  250.   PlayMode(PlayerFrameMode, start, end);
  251.   
  252.   /* Reset search status */
  253.   value = xv_get(VideoEdit_optionsPopup->optionsSearchStg, PANEL_VALUE);
  254.   if (value == 1) 
  255.     DevSetAddMode(myVideo, PlayerChapterMode);
  256. }
  257.  
  258. /*
  259.  * Notify callback function for `previewPlayLastTxt'.
  260.  */
  261. Panel_setting
  262. PreviewEndTxt(item, event)
  263.      Panel_item    item;
  264.      Event        *event;
  265. {
  266.   
  267.   if (event_action(event) != '\r')
  268.     return (0);
  269.   if (search == 1)
  270.     search = 0;
  271.   else 
  272.   {
  273.     PreviewEnd(item, event);
  274.     search = 1;
  275.   }
  276.   
  277. }
  278.  
  279.  
  280. /*
  281.  * Notify callback function for `previewDoneButton'.
  282.  * Close the preview popup window
  283.  */
  284. void
  285. PreviewDone(item, event)
  286.      Panel_item      item;
  287.      Event           *event;
  288. {
  289.   xv_set(VideoEdit_previewPopup->previewPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  290.   xv_set(VideoEdit_previewPopup->previewPopup, XV_SHOW, FALSE, NULL);
  291.   
  292. }
  293.